#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    string s1, s2;
    cin >> s1 >> s2;
    int pos1 = s1.find(".");
    if (pos1 == -1)
    {
        pos1 = s1.size();
        s1 += '.';
    }
    int pos2 = s2.find(".");
    if (pos2 == -1)
    {
        pos2 = s2.size();
        s2 += '.';
    }
    if (pos1 != pos2)
    {
        cout << "NO";
        return;
    }
    for (int i = 0; i < pos1; i++)
    {
        if (s1[i] != s2[i])
        {
            cout << "NO";
            return;
        }
    }
    string a(s1.begin() + pos1, s1.end());
    string b(s2.begin() + pos2, s2.end());
    if (a.size() < 7)
        for (int i = 7 - a.size(); i >= 1; i--)
            a += '0';
    else
        a = a.substr(0, 7);
    if (b.size() < 7)
        for (int i = 7 - b.size(); i >= 1; i--)
            b += '0';
    else
        b = b.substr(0, 7);
    if (a == b)
        cout << "YES";
    else
        cout << "NO";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}